package glazedlists.chapter4;

import ca.odell.glazedlists.EventList;
import ca.odell.glazedlists.TransformedList;
import ca.odell.glazedlists.event.ListEvent;
import ca.odell.issuezilla.Issue;

public class IssueToUserList extends TransformedList<Issue, String> {

    public IssueToUserList(EventList<Issue> source) {
        super(source);
        source.addListEventListener(this);
    }

    @Override
    public String get(int index) {
        Issue issue = source.get(index);
        return issue.getReporter();
    }

    @Override
    public void listChanged(ListEvent<Issue> listEvent) {
        updates.forwardEvent(listEvent);
    }

    @Override
    protected boolean isWritable() {
        return false;
    }
}
